<template>
	<view>
		<scroll-view scroll-x class="text-gray nav padding-lr" scroll-with-animation :scroll-left="scrollLeft">
			<view class="flex text-center">
				<view class="cu-item flex-sub" :class="i.id==TabCur?'active cur':''" v-for="i in tab" :key="i.id" @tap="tabSelect" :data-id="i.id">
					{{i.text}}
				</view>
			</view>
		</scroll-view>
		<view class="padding-bottom-xs" style="background-color: #EFEFEF;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0,
				tab: [{
						id: 0,
						text: '全部'
					},
					{
						id: 1,
						text: '待付款'
					},
					{
						id: 2,
						text: '已付款'
					},
					{
						id: 3,
						text: '已完成'
					}
				],
			}
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nav {
		position: sticky;
		background-color: #fff;
		top: 0;
		z-index: 9999;
		
		.active {
			color: #1f1f1f;
			font-weight: bold;
		}
	}
</style>
